﻿function ULS_SP() {
    if (ULS_SP.caller) {
        ULS_SP.caller.ULSTeamName = "Windows SharePoint Services 4";
        ULS_SP.caller.ULSFileName = "RibbonApp.UI.js";
    } 
}

Type.registerNamespace('RibbonApp.UI');

// RibbonApp Page Component
RibbonApp.UI.RibbonAppPageComponent = function() {
    ULS_SP();
    RibbonApp.UI.RibbonAppPageComponent.initializeBase(this);
}
RibbonApp.UI.RibbonAppPageComponent.initialize = function() {
    ULS_SP();
    ExecuteOrDelayUntilScriptLoaded(Function.createDelegate(null, RibbonApp.UI.RibbonAppPageComponent.initializePageComponent), 'SP.Ribbon.js');
}
RibbonApp.UI.RibbonAppPageComponent.initializePageComponent = function() {
    ULS_SP();
    var ribbonPageManager = SP.Ribbon.PageManager.get_instance();
    if (null !== ribbonPageManager) {
        ribbonPageManager.addPageComponent(RibbonApp.UI.RibbonAppPageComponent.instance);
        ribbonPageManager.get_focusManager().requestFocusForComponent(RibbonApp.UI.RibbonAppPageComponent.instance);
    }
}
RibbonApp.UI.RibbonAppPageComponent.refreshRibbonStatus = function() {
    SP.Ribbon.PageManager.get_instance().get_commandDispatcher().executeCommand(Commands.CommandIds.ApplicationStateChanged, null);
}
RibbonApp.UI.RibbonAppPageComponent.prototype = {
    getFocusedCommands: function() {
        ULS_SP();
        return [];
    },
    getGlobalCommands: function() {
        ULS_SP();
        return getGlobalCommands();
    },
    isFocusable: function() {
        ULS_SP();
        return true;
    },
    receiveFocus: function() {
        ULS_SP();
        return true;
    },
    yieldFocus: function() {
        ULS_SP();
        return true;
    },
    canHandleCommand: function(commandId) {
        ULS_SP();
        return commandEnabled(commandId);
    },
    handleCommand: function(commandId, properties, sequence) {
        ULS_SP();
        return handleCommand(commandId, properties, sequence);
    }
}


// Register classes
RibbonApp.UI.RibbonAppPageComponent.registerClass('RibbonApp.UI.RibbonAppPageComponent', CUI.Page.PageComponent); 
RibbonApp.UI.RibbonAppPageComponent.instance = new RibbonApp.UI.RibbonAppPageComponent(); 

// Notify waiting jobs
NotifyScriptLoadedAndExecuteWaitingJobs("ribbonapp.ui.js");